package org.edith.log.service.impl;

import org.edith.log.dataobject.LogDO;
import org.edith.log.service.LoggerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.edith.log.dao.LogDAO;

import javax.annotation.PostConstruct;

@Service("edithWebLoggerService")
public class LoggerServiceImpl implements LoggerService {
    @Autowired
    private LogDAO logDAO;

    /**
     * 向数据库插入日志记录
     *
     * @param model
     */
    @Override
    public void insertLog(LogDO model) {
        logDAO.insertLog(model);
    }


    /**
     * 检查日志记录表是否存在,如果不存在则创建日志记录表
     */
    @PostConstruct
    private void checkLogTable() {
        logDAO.createLogTable();
    }

}
